package com.rms.hkpc.presenter;


import com.google.gson.reflect.TypeToken;
import com.rms.hkpc.apiresult.ApiResultData;
import com.rms.hkpc.apiresult.PagedList;
import com.rms.hkpc.db.dto.WorkOrderRecordDto;
import com.rms.hkpc.db.dto.WorksOrderDto;
import com.rms.hkpc.db.query.BaseQuery;
import com.rms.hkpc.model.listener.OnResultListener;
import com.rms.hkpc.model.RecordsModel;
import com.rms.hkpc.view.IRecordsConView;

public class RecordsConPresenter extends BasePresenter<IRecordsConView> {
    private RecordsModel recordsModel = new RecordsModel();

    public void getData(BaseQuery query) {
        recordsModel.getData(query, new OnResultListener() {
            @Override
            public void onSuccess(Object apiResult) {
                if (getView() != null) {
                    getView().onGetDataSuccess((ApiResultData<PagedList<WorkOrderRecordDto>>) apiResult);
                }
            }

            @Override
            public void onFails(Exception e) {
                if (getView() != null) {
                    getView().onGetDataFails(e);
                }
            }
        }, new TypeToken<ApiResultData<PagedList<WorkOrderRecordDto>>>() {
        }.getType());
    }
}
